import { OkComponent } from '../common/component';
/**
 * api
 *  Event
 *    1.leftEvent（点击home图标的自定义事件）:需要传入leftEvent为真
 *    2.homeEvent（点击home图标的自定义事件）:需要传入homeEvent为真默认指向/pages/benefit/benefit页
 */

OkComponent({
  /**
   * 组件的属性列表
   */
  props: {
    insetTop: {
      type: Boolean,
      value: false
    },
    title: String,
    leftText: String,
    leftEvent: Boolean,
    leftArrow: Boolean,
    homeArrow: Boolean,

    homeEvent: Boolean,
    homeUrl: {
      type: String,
      value: "/pages/benefit/benefit",
    },
    fixed: {
      type: Boolean,
      value: true
    },
    zIndex: {
      type: Number,
      value: 9999
    },
    noLine: {
      type: Boolean,
      value: true
    },
    customStyle: {
      type: String,
      value: ""
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    statusBarHeight: 0
  },
  /**生命周期对象 */
  created() {
    const { statusBarHeight } = wx.getSystemInfoSync();
    this.setData({ statusBarHeight: statusBarHeight });
  },
  /**
   * 组件的方法列表
   */
  methods: {

    /**点击左侧回到指定页面 */
    bindNavigator(e){
      if (this.data.leftEvent){
        this.$emit("leftEvent");
      }else{
        wx.navigateBack();
      }
    },
    /**回到首页 */
    bindNavigatorIndex(){
      if (this.data.homeEvent) {
        this.$emit("homeEvent");
      } else {
        let homeUrl = this.data.homeUrl;
        wx.switchTab({
          url: homeUrl,
        });
      }
    },

    bindLeft(){
      this.$emit('click-left');
    }
  }
})
// Component({

// })
